﻿<cfsilent>
	<cfscript>
	
		event.setArg("pageTitle", "课程补考成绩底单");
		
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		markAdvice = getProperty("serviceFactory").getBean("markAdvice");
		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		
		taskId = event.getArg("TSK");
		taskType = event.getArg("TT");
		
		/* 载入教学任务 */
		switch(taskType){

			case 'P':
				sql = "	SELECT
							tsk.term_id,c.course_code,i.institute_name,c.course_name,tch.tch_name,tsk.cidx,tch.tch_id,t.academic_year,t.academic_term,c.course_credit
						FROM
							t_task tsk
							INNER JOIN t_course c ON tsk.cid = c.cid
							INNER JOIN t_institute i ON i.institute_id = c.institute_id
							INNER JOIN t_teacher tch ON tch.tch_id = tsk.tch_id
							INNER JOIN t_term t ON t.term_id = tsk.term_id
						WHERE
							tsk.tsk_id = :taskId ";
							
				queryObj = new Query(datasource = application.dnsSlave);
				queryObj.addParam(name = "taskId", value=taskId, cfsqltype="cf_sql_varchar");
				rs_taskEntity = queryObj.execute(sql = sql).getResult();
				
				break;
			
			case 'C':
				sql = "	SELECT
							tsk.term_id,c.course_code,i.institute_name,c.course_name,tch.tch_name,tsk.cidx,tch.tch_id,t.academic_year,t.academic_term,c.course_credit
						FROM
							t_common_task tsk
							INNER JOIN t_course c ON tsk.cid = c.cid
							INNER JOIN t_institute i ON i.institute_id = c.institute_id
							INNER JOIN t_teacher tch ON tch.tch_id = tsk.tch_id
							INNER JOIN t_term t ON t.term_id = tsk.term_id
						WHERE
							tsk.tsk_id = :taskId ";
							
				queryObj = new Query(datasource = application.dnsSlave);
				queryObj.addParam(name = "taskId", value=taskId, cfsqltype="cf_sql_varchar");
				rs_taskEntity = queryObj.execute(sql = sql).getResult();
				
				break;
				
			case 'R':
				sql = "	SELECT
							tsk.term_id,c.course_code,i.institute_name,c.course_name,tch.tch_name,tsk.cidx,tch.tch_id,t.academic_year,t.academic_term,c.course_credit
						FROM
							t_reopen_task tsk
							INNER JOIN t_course c ON tsk.cid = c.cid
							INNER JOIN t_institute i ON i.institute_id = c.institute_id
							INNER JOIN t_teacher tch ON tch.tch_id = tsk.tch_id
							INNER JOIN t_term t ON t.term_id = tsk.term_id
						WHERE
							tsk.tsk_id = :taskId ";
							
				queryObj = new Query(datasource = application.dnsSlave);
				queryObj.addParam(name = "taskId", value=taskId, cfsqltype="cf_sql_varchar");
				rs_taskEntity = queryObj.execute(sql = sql).getResult();
				
				break;

			case 'T':

				sql = "	SELECT
							tsk.term_id,c.course_code,i.institute_name,c.course_name,tch.tch_name,tsk.cidx,tch.tch_id,t.academic_year,t.academic_term,c.course_credit
						FROM
							t_sport_task tsk
							INNER JOIN t_course c ON tsk.cid = c.cid
							INNER JOIN t_institute i ON i.institute_id = c.institute_id
							INNER JOIN t_teacher tch ON tch.tch_id = tsk.tch_id
							INNER JOIN t_term t ON t.term_id = tsk.term_id
						WHERE
							tsk.tsk_id = :taskId ";
							
				queryObj = new Query(datasource = application.dnsSlave);
				queryObj.addParam(name = "taskId", value=taskId, cfsqltype="cf_sql_varchar");
				rs_taskEntity = queryObj.execute(sql = sql).getResult();
				
				break;
		}
		
		/* 学校信息 */
		sql = "SELECT
					s.sch_name
				FROM
					t_school s";
		
		queryObj = new Query(datasource = application.dnsSlave);
		rs_schoolEntity = queryObj.execute(sql = sql).getResult();
		
		/* 成绩数据 */
		sql = "	SELECT
					sm.stu_id,stu.stu_name,clz.cls_name,clz.grade,
					sm.retaking,
					sm.mark_mode,sm.mark_resit,sm.mark_renote,sm.mark_resit_limit
				FROM
					t_student_mark sm
					INNER JOIN t_student stu ON stu.stu_id = sm.stu_id
					INNER JOIN t_class clz ON clz.cls_id = stu.cls_id
				WHERE
					sm.task_id = :taskId 
					AND
					sm.mark_resit > -1
				ORDER BY
					sm.stu_id";
		
		queryObj = new Query(datasource = application.dnsSlave);
		queryObj.addParam(name = "taskId", value=taskId, cfsqltype="cf_sql_varchar");
		rs_chooser = queryObj.execute(sql = sql).getResult();
		
		rowPerPage = 40;
		
		if ( rs_chooser.recordCount mod rowPerPage ) {
			totlePageCount = int(rs_chooser.recordCount/rowPerPage) + 1;
		}
		else {
			totlePageCount = int(rs_chooser.recordCount/rowPerPage);
		}
		
		pageRowBegin = 1;
		pageRowEnd = min(rowPerPage, rs_chooser.recordCount);
		
		tagCode = "CJBD-" & rs_taskEntity.term_id & "," & rs_taskEntity.course_code & "," & rs_taskEntity.cidx;
				
	</cfscript>
</cfsilent>

<cfloop from="1" to="#totlePageCount#" index="currentPage">
	<cfif currentPage GT 1>
		<div class="page_break"></div>
	</cfif>
	<div class="UIprintableTitle"><cfoutput>#rs_schoolEntity.sch_name#</cfoutput>课程补考成绩单</div>
	<table width="98%" border="0" cellpadding="1" cellspacing="0">
		<tr>
			<td>任课单位 <cfoutput>#rs_taskEntity.institute_name#</cfoutput></td>
			<td>教学班 <cfoutput>#rs_taskEntity.course_name#</cfoutput>-<cfoutput>#rs_taskEntity.tch_name#</cfoutput>-<cfoutput>#rs_taskEntity.cidx#</cfoutput></td>
			<td>教师 [<cfoutput>#rs_taskEntity.tch_id#</cfoutput>]<cfoutput>#rs_taskEntity.tch_name#</cfoutput></td>
			<td align="right">成绩记录 <cfoutput>#rs_chooser.recordCount#</cfoutput>条</td>
		</tr>
		<tr>
			<td>学期 <cfoutput>#rs_taskEntity.academic_year#</cfoutput>-<cfoutput>#rs_taskEntity.academic_term#</cfoutput></td>
			<td>课程
				<cfif rs_taskEntity.course_code neq "">
					[<cfoutput>#rs_taskEntity.course_code#</cfoutput>]
				</cfif>
				<cfoutput>#rs_taskEntity.course_name#</cfoutput></td>
			<td>学分 <cfoutput>#numberFormat(rs_taskEntity.course_credit, "_.__")#</cfoutput></td>
			<td align="right">第<cfoutput>#currentPage#</cfoutput>页 共<cfoutput>#totlePageCount#</cfoutput>页</td>
		</tr>
	</table>
	<table class="UIprintable" width="100%" border="1" cellpadding="5" cellspacing="1">
		<thead>
			<tr>
				<td>序</td>
				<td>学号</td>
				<td>姓名</td>
				<td>班级</td>
				<td>年级</td>
				<td>重修</td>
				<td>成绩</td>
			</tr>
		</thead>
		<tbody>
			<cfloop index="row" from="#pageRowBegin#" to="#pageRowEnd#">
				<tr>
					<td><cfoutput>#row#</cfoutput></td>
					<td><cfoutput>#rs_chooser['stu_id'][row]#</cfoutput></td>
					<td><cfoutput>#rs_chooser['stu_name'][row]#</cfoutput></td>
					<td><cfoutput>#rs_chooser['cls_name'][row]#</cfoutput></td>
					<td><cfoutput>#rs_chooser['grade'][row]#</cfoutput></td>
					<td><cfif yesNoFormat(rs_chooser['retaking'][row])>是<cfelse>&nbsp;</cfif></td>
					<td><cfoutput>#markAdvice.getMarkResit( rs_chooser['mark_mode'][row], rs_chooser['mark_resit'][row], rs_chooser['mark_renote'][row], rs_chooser['mark_resit_limit'][row] )#</cfoutput></td>
				</tr>
			</cfloop>
		</tbody>
	</table>
	<div class="clear2px"></div>
	<table width="100%" cellpadding="0" cellspacing="0">
		<tr>
			<td>打印时间 <cfoutput>#dateFormat(now(), "YYYY年MM月DD日")#</cfoutput></td>
			<td>教师签字</td>
			<td align="right"><img src="<cfoutput>#getContextRoot()#</cfoutput>/barcode/Print/<cfoutput>#tagCode#</cfoutput>.png" height="43"/></td>
		</tr>
	</table>
	<cfset pageRowBegin = pageRowBegin + rowPerPage />
	<cfset pageRowEnd = pageRowEnd + rowPerPage />
	<cfif pageRowEnd gt rs_chooser.recordCount>
		<cfset pageRowEnd = rs_chooser.recordCount />
	</cfif>
</cfloop>
